package implementor;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc;

public class CutoutFilter implements Filter {
    
    @Override
    public Mat apply(Mat image) {
        Mat result = new Mat();
        
        // 转换为灰度图
        Mat grayImage = new Mat();
        Imgproc.cvtColor(image, grayImage, Imgproc.COLOR_BGR2GRAY);
        
        // 应用自适应阈值处理，模拟木刻效果
        Mat thresholdImage = new Mat();
        Imgproc.adaptiveThreshold(grayImage, thresholdImage, 255, 
                Imgproc.ADAPTIVE_THRESH_MEAN_C, 
                Imgproc.THRESH_BINARY, 9, 5);
        
        // 转回彩色图像
        Imgproc.cvtColor(thresholdImage, result, Imgproc.COLOR_GRAY2BGR);
        
        return result;
    }
    
    @Override
    public String getName() {
        return "Cutout";
    }
}